import {
	BASE_URL
} from "./config.js"

const request = (url, data = {}, method) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: BASE_URL + url,
			data,
			method,
			header: {
				"Authorization": uni.getStorageSync("token")
			},
			success: (res) => {
				resolve(res.data)
			},
			fail: (error) => {
				
				uni.showToast({
					title:"请求失败",icon:"error"
				})
				reject(error)
			}
		})
	})
}

export const get = (url, data) => {
	return request(url, data, "get")
}
export const post = (url, data) => {
	return request(url, data, "post")
}